Skip to content

Feat: Re-export every manifest module by one naming rule over the binder's Kotlin names - #21

Merged
b-re-w merged 1 commit into
developfrom
work/reexport
Oct 2, 2026
Merged

b-re-w merged 1 commit into
developfrom
work/reexport

Conversation

@b-re-w

@b-re-w b-re-w commented Oct 2, 2026

Copy link
Copy Markdown
Member

Closes #8

One rule, pythonx/compose/_reexport.py, makes every pythonx-map.toml module a Pythonic view of its androidx.compose.* module, reading the binder's published contract (inspect.signature, python_multiplatform.describe). There are no per-widget wrappers (AGENTS.md §13).

Public surface

  • Names: upper-case names (Modifier, Text) keep their Kotlin spelling; everything else is snake_case only (padding_values_of, to_url_string); explicit overloads keep their suffix (padding__Dp_Dp). The rule is applied forward and never inverted, and collisions are refused by name.
  • Keywords: padding_values= → paddingValues, matched against every overload's own parameter names. An unknown keyword reaches the binder's refusal, which lists the candidates.
  • Signatures: inspect.signature reports snake_case names and keeps KOTLIN_DEFAULT.
  • Value classes: the manifest allowlist reaches the binder when a pythonx.compose module first resolves a name.
  • Laziness: importing needs no binder; without one, reading a name raises a RuntimeError that names PythonxAdapter.install().

Feature added: the rule; package files for foundation, foundation.layout, ui.text, ui.graphics (manifest rows that had no file).
Test added/rewritten: test_chain.py against pythonx (36 tests, 4 skip pending python-multiplatform #17 → #20); test_modifier_module.py and test_runtime_module.py import normally.
Red: the new tests against develop: 31 failed, 18 passed, 4 skipped. Disabling the name rule fails 15 tests, the keyword mapping 1, the allowlist 12.
Documentation corrected: SPEC §0, §3, S4.1, S5.1, S5.2, S6.x; PROJECT.md; AGENTS.md §14; guide status and baseline; package docstrings.
Not here: snake_case methods on a proxy the binder returned (#20, needs python-multiplatform #17).

Environment Before After
No PythonMultiplatform checkout 40 passed, 37 skipped 40 passed, 45 skipped
../PythonMultiplatform (develop d00f413f) 44 passed, 33 failed 81 passed, 4 skipped

Each test module also passes when run on its own. tools/check_guide.py: 0 findings.

…der's Kotlin names

The binder serves androidx.compose.* under Kotlin names only and publishes
inspect.signature and python_multiplatform.describe for a Pythonic layer to
read. This is that layer, as one rule in pythonx/compose/_reexport.py: each
module in pythonx-map.toml is a file on disk whose __init__ hands its name to
reexport(), and a name read from it resolves on first use.

- Upper-case names (types, objects, composables) keep their Kotlin spelling;
  every other name is reached by its snake_case spelling only, and an explicit
  overload keeps its suffix. The rule is applied forward to the Kotlin
  module's real names and looked up, never inverted, so toURLString is
  to_url_string and a collision is refused by name.
- Keywords are matched to the declaration's own parameter names from
  describe(), every overload's; an unmatched keyword reaches the binder's own
  refusal unchanged. inspect.signature reports snake_case names and keeps
  KOTLIN_DEFAULT.
- The manifest's raw-primitive allowlist reaches the binder once per
  installed binding layer.
- Names a package defines itself (runtime.Composable) win; resolution is lazy,
  so importing a pythonx.compose module needs no binder.

foundation/, foundation/layout/, ui/text/ and ui/graphics/ get the one-line
__init__ their manifest rows already promised. ui/modifier.py drops the
synthetic-pythonx lookup and reaches Modifier through pythonx.compose.ui.

Methods on a proxy the binder returned (m.fill_max_width()) are the binder's
class's attributes and wait for its member resolver (python-multiplatform
#17, issue #20); the 4 tests that need it skip.

feature added: the re-export rule, the four missing package files.
test added/rewritten: test_chain.py against pythonx (Names 8, Laziness 5,
OverloadDispatch 7, ValueClasses 6, TheChain 6, Handles 1, sources 3),
test_modifier_module.py and test_runtime_module.py import normally.
Red: the new tests against develop, 31 failed, 18 passed, 4 skipped.
Disabling the name rule fails 15, the keyword mapping 1, the allowlist 12.
documentation corrected: SPEC 0/3/S4.1/S5.1/S5.2/S6.x, PROJECT.md, AGENTS.md
section 14, guide status and baseline, three package docstrings.
Suite with ../PythonMultiplatform (develop d00f413f): 44 passed, 33 failed ->
81 passed, 4 skipped. Without a checkout: 40 passed, 37 skipped -> 40 passed,
45 skipped. Each test module run separately passes. check_guide.py: 0.

Refs #8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant